package com.example.springbootdemo.bean;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Slf4j
@Data
public class Bean3 implements Inter{
  public Bean3(){
    log.debug("constructor bean3");
  }

  private Bean2 bean2;

  @Autowired
  private Bean1 bean1;

  @Autowired
  public void setBean2(Bean2 bean2) {
    log.info("@Autowired 生效: {}", bean2);
    this.bean2 = bean2;
  }
  @Resource
  public void setBean1(Bean1 bean1) {
    log.info("@Resource 生效: {}", bean1);
    this.bean1 = bean1;
  }

  private String home;

  @Autowired
  public void setHome(@Value("${JAVA_HOME}") String home) {
    log.info("@Value 生效: {}", home);
    this.home = home;
  }

  @PostConstruct
  public void init() {
    log.info("@PostConstruct 生效");
  }

  @PreDestroy
  public void destroy() {
    log.info("@PreDestroy 生效");
  }
}
